#include <iostream>
#include <vector>

namespace csb {
  template <class T> void unordered_combinations(const std::vector<T>& choose_from, 
						 std::vector<std::vector<T> >& all_combos, 				   
						 size_t n_per_combo) 
  {
    std::vector<T> t;
    
    unordered_recurse_combinations(choose_from, all_combos, t, 0, n_per_combo);
  }
  
  template <class T> void unordered_recurse_combinations(const std::vector<T>& choose_from,
							 std::vector<std::vector<T> >& output, 
							 std::vector<T>& temp,
							 size_t array_index, size_t step_val)
  {
    if (step_val == 0) {
      output.push_back(temp);
      return;
    }
    
    for (int i = array_index; i < choose_from.size(); i++) {
      temp.push_back(choose_from[i]);
      unordered_recurse_combinations(choose_from, output, temp, i+1, step_val-1);
      temp.pop_back();
    }
    
  return; 
  }
  
}
